//顺序表

//顺序表的类型定义

template<typename E, int MAXSIZE>
struct SqList
{
    E elem[MAXSIZE];  
    int length;  
};

//初始化空表

template<typename E, int M>

    void InitList(SqList<E ,M> &L)  
    {
        L.length = 0;
    }
//在顺序表L中第i个位置插入元素e  
template<typename E, int MAXSIZE>

void ListInsert(SqList<E,MAXSIZE> &L,int i,E e)
{
    if(L. length == MAXSIZE) throw"List if full" ;
    if (i<1 || i>L. length+1)throw"i out of range" ;

    for (int j=L.length-1; j>=i-1; j--)
    {
        L.elem[j+1]=L.elem[j]; 
    }

    L.elem[i-1]=e;

    L.length++;
}
//删除顺序表L中的第1个元素，用e返回  
template<typename E,int MAXSIZE>
void ListDelete(SqList<E ,MAXSIZE>&L,int i,E &e)
{
    if(L. length==0)throw"List is empty" ;
    if (i<1 || i>L. length)throw"i out range" ;

    e=L.elem[i-1];
    for (int j = i; j < L.length; j++)
    {
        L.elem[j-1]=L.elem[j]; 
    }
    L.length--;
}